package com.zlx.mall.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zlx.mall.base.entity.ScUser;
import com.zlx.mall.base.mapper.ScUserMapper;
import com.zlx.mall.base.service.IScUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zlx.mall.basic.common.enums.NotDeteteEnum;
import com.zlx.mall.basic.mask.DataMaskHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户 服务实现类
 * </p>
 *
 * @author xiatian
 * @since 2025-03-23
 */
@Service
public class ScUserServiceImpl extends ServiceImpl<ScUserMapper, ScUser> implements IScUserService {
    @Autowired
    private DataMaskHandler dataMaskHandler;

    @Override
    public ScUser selectByMobile(String mobile) {
        return this.baseMapper.selectOne(new QueryWrapper<ScUser>().eq(ScUser.MOBILE_MD5, dataMaskHandler.md5(mobile)).eq(ScUser.IS_DELETE, NotDeteteEnum.NOT_DELETE.getCode()));
    }

    @Override
    public ScUser selectById(Long userId) {
        return this.baseMapper.selectOne(new QueryWrapper<ScUser>().eq(ScUser.ID, userId).eq(ScUser.IS_DELETE, NotDeteteEnum.NOT_DELETE.getCode()));
    }
}
